package cn.uc.usedcar.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * @author:yuziji
 * @create: 2023-06-01 10:09
 * @description:封装统一返回结果
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class ResultVo {
    private Integer code;
    private String message;
    private Object data;

    public ResultVo(Integer code,String message){
        this.code = code;
        this.message = message;
    }

    public ResultVo(StatusCode statusCode,Object data){
        this(statusCode);
        this.data = data;
    }

    public ResultVo(StatusCode statusCode){
        this.code = statusCode.getCode();
        this.message = statusCode.getMessage();
    }

    public static ResultVo ok(Object data){
        ResultVo resultVo = new ResultVo(StatusCode.SUCCESS,data);
        return resultVo;
    }

    public static ResultVo ok(){
        return ok(null);
    }

}
